/*     */ package server.console;
/*     */
/*     */ import client.inventory.MapleInventoryIdentifier;
/*     */ import com.alee.extended.label.WebHotkeyLabel;
/*     */ import com.alee.extended.painter.Painter;
/*     */ import com.alee.extended.painter.TitledBorderPainter;
/*     */ import com.alee.extended.panel.GroupPanel;
/*     */ import com.alee.extended.progress.WebProgressOverlay;
/*     */ import com.alee.extended.statusbar.WebMemoryBar;
/*     */ import com.alee.extended.statusbar.WebStatusBar;
/*     */ import com.alee.global.StyleConstants;
/*     */ import com.alee.laf.WebLookAndFeel;
/*     */ import com.alee.laf.button.WebButton;
/*     */ import com.alee.laf.combobox.WebComboBox;
/*     */ import com.alee.laf.label.WebLabel;
/*     */ import com.alee.laf.menu.WebPopupMenu;
/*     */ import com.alee.laf.optionpane.WebOptionPane;
/*     */ import com.alee.laf.panel.WebPanel;
/*     */ import com.alee.laf.progressbar.WebProgressBar;
/*     */ import com.alee.laf.rootpane.WebFrame;
/*     */ import com.alee.laf.scroll.WebScrollBar;
/*     */ import com.alee.laf.scroll.WebScrollPane;
/*     */ import com.alee.laf.separator.WebSeparator;
/*     */ import com.alee.laf.text.WebTextField;
/*     */ import com.alee.laf.text.WebTextPane;
/*     */ import com.alee.utils.ThreadUtils;
/*     */ import configs.*;
/*     */
/*     */
/*     */ import constants.GameConstants;
import constants.ItemConstants;
/*     */ import constants.ServerConstants;
/*     */ import database.DatabaseConnection;
/*     */ import handling.Auction.AuctionServer;
/*     */ import handling.cashshop.CashShopServer;
/*     */ import handling.channel.ChannelServer;
/*     */ import handling.channel.MapleDojoRanking;
/*     */ import handling.channel.MapleGuildRanking;
/*     */ import handling.channel.PlayerStorage;
/*     */ import handling.chat.ChatServer;
/*     */ import handling.login.LoginInformationProvider;
/*     */ import handling.login.LoginServer;
/*     */ import handling.world.World;
/*     */ import handling.world.WorldBroadcastService;
/*     */ import handling.world.WorldRespawnService;
/*     */ import handling.world.family.MapleFamily;
/*     */ import handling.world.guild.MapleGuild;
/*     */ import handling.world.messenger.MessengerRankingWorker;
/*     */ import java.awt.BorderLayout;
/*     */ import java.awt.Color;
/*     */ import java.awt.Component;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Frame;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.event.ActionEvent;
/*     */ import java.awt.event.ActionListener;
/*     */ import java.awt.event.ItemEvent;
/*     */ import java.awt.event.MouseWheelEvent;
/*     */ import java.awt.event.WindowAdapter;
/*     */ import java.awt.event.WindowEvent;
/*     */ import java.io.IOException;
/*     */ import java.io.OutputStream;
/*     */ import java.io.PrintStream;
/*     */ import java.net.ServerSocket;
/*     */ import java.util.Observable;
/*     */ import java.util.Observer;
/*     */ import java.util.Properties;
/*     */ import java.util.Scanner;
import java.util.concurrent.ScheduledFuture;
/*     */ import javax.swing.ImageIcon;
/*     */ import javax.swing.JPopupMenu;
/*     */ import javax.swing.SwingUtilities;
/*     */ import javax.swing.SwingWorker;
/*     */ import javax.swing.plaf.FontUIResource;
/*     */ import javax.swing.text.BadLocationException;
/*     */ import javax.swing.text.SimpleAttributeSet;
/*     */ import org.apache.logging.log4j.LogManager;
/*     */ import org.apache.logging.log4j.Logger;
/*     */ import server.AutoExecuteTask;
/*     */ import server.AutobanManager;
/*     */ import server.CharacterCardFactory;
/*     */ import server.InitializeServer;
/*     */ import server.MTSStorage;
/*     */ import server.MapleItemInformationProvider;
/*     */ import server.MapleSignin;
/*     */ import server.MapleUnionFactory;
/*     */ import server.PlayMSEvent;
/*     */ import server.PredictCardFactory;
/*     */ import server.RandomRewards;
/*     */ import server.RankingTop;
/*     */ import server.RankingWorker;
/*     */ import server.ShutdownServer;
/*     */ import server.SpeedRunner;
/*     */ import server.Timer;
/*     */ import server.carnival.MapleCarnivalFactory;
/*     */ import server.commands.CommandProcessor;
/*     */ import server.console.groups.boss.BossManagePanel;
/*     */ import server.console.groups.database.DataBaseManagePanel;
/*     */ import server.console.groups.datamanage.DataManagePanel;
/*     */ import server.console.groups.setting.ConfigPanel;
/*     */ import server.console.groups.update.UpdateServer;
/*     */ import server.console.groups.wztools.WZStringDumperPane;
/*     */ import server.life.PlayerNPC;
/*     */ import tools.Authorization;
/*     */ import tools.MaplePacketCreator;
/*     */ import tools.Pair;
/*     */ import tools.StringUtil;
import tools.config.ConfigurableProcessor;
import tools.ppms.AuthCheckUtil;

/*     */
/*     */ public class Start extends WebFrame {
    /*  91 */   private static final Logger log = LogManager.getLogger(Start.class.getName());
    /*     */
    /*     */   public static boolean startFinish = false;
    /*     */
    /*  93 */   private static Start instance = null;
    /*     */
    /*     */   private final StartFrame progress;
    /*     */
    /*     */   private final Thread start_thread;
    /*     */
    /*     */   private final String server_version;
    /*     */
    /*     */   private WebTextPane textPane;
    /*     */
    /*  98 */   private long starttime = 0L;
    /*     */
    /*     */   private ScheduledFuture<?> shutdownServer;
    /*     */
    /*     */   private ScheduledFuture<?> startRunTime;
    /*     */
    /*     */   private WebHotkeyLabel[] labels;
    /*     */
    /*     */   private boolean autoScroll = true;
    /*     */
    /*     */   private WebHotkeyLabel runningTimelabel;
    /*     */
    /*     */   private DatabaseConnection.DataBaseStatus dataBaseStatus;
    /*     */
    /*     */   private WebLabel authLimitTime;
    /*     */
    /*     */   public Start() {
        /* 107 */     this.start_thread = new Thread(new StartThread());
        /* 110 */     WebPanel contentPane = new WebPanel();
        /* 112 */     contentPane.setPreferredSize(1000, 600);
        /* 113 */     setMinimumSize(contentPane.getPreferredSize());
        /* 115 */     Timer.GuiTimer.getInstance().start();
        /* 117 */     ProgressBarObservable progressBarObservable = new ProgressBarObservable();
        /* 118 */     ProgressBarObserver progressBarObserver = new ProgressBarObserver(progressBarObservable);
        /* 120 */     this.progress = createProgressDialog();
        /* 121 */     this.progress.addWindowListener(new WindowAdapter() {
            /*     */           public void windowClosed(WindowEvent e) {
                /* 124 */             System.exit(0);
                /*     */           }
            /*     */         });
        /* 128 */     this.progress.setIconImage(getMainIcon().getImage());
        /* 129 */     this.progress.setTitle("服务端正在启动...");
        /* 130 */     setIconImage(getMainIcon().getImage());
        /* 131 */     setLayout(new BorderLayout());
        /* 133 */     Properties properties = new Properties();
        /*     */     try {
            /* 135 */       properties.load(Start.class.getClassLoader().getResourceAsStream("application.properties"));
            /* 136 */     } catch (IOException e) {
            /* 137 */       e.printStackTrace();
            /*     */     }
        /* 139 */     this.server_version = properties.getProperty("version");
        /* 141 */     progressBarObservable.setProgress(new Pair("初始化配置...", Integer.valueOf(0)));
        /* 142 */     Config.load();
        /* 143 */     progressBarObservable.setProgress(new Pair("检查网络状态...", Integer.valueOf(10)));
        /* 144 */     Authorization.getBJTime();
        /* 145 */     progressBarObservable.setProgress(new Pair("检查授权信息...", Integer.valueOf(20)));
        /* 146 */     Pair<Authorization.AuthStatus, String> authPair = Authorization.checkAuth();
        /* 147 */     log.info(authPair);
        /* 148 */     if (authPair.getLeft() != Authorization.AuthStatus.AUTH_SUCCESS && authPair.getLeft() != Authorization.AuthStatus.AUTH_NOCHECK) {
            /* 149 */       if (authPair.getLeft() == Authorization.AuthStatus.AUTH_TIMEOUT) {
                /* 150 */         WebOptionPane.showMessageDialog((Component)instance, "授权时间到期");
                /* 151 */         System.exit(1);
                /*     */   }
            /* 153 */       if (ShutdownServer.running) {
                /* 154 */         ShutdownServer.getInstance().shutdown();
                /*     */       } else {
                /* 156 */         WebOptionPane.showInputDialog((Component)instance, "本机尚未授权，请复制授权码，并联系作者", authPair.getRight());
                /* 157 */         System.exit(1);
                /*     */       }
            /* 159 */     } else if (authPair.getLeft() != Authorization.AuthStatus.AUTH_NOCHECK) {
            /* 160 */       Authorization.AutoCheckAuth();
            /*     */     }
        try {
            String checkstr= AuthCheckUtil.checkMapleAuth();
            String[] res= tools.ppms.StringUtil.decode(checkstr).split(",");
            Process process = Runtime.getRuntime().exec(
                    new String[]{"wmic", "cpu", "get", "ProcessorId"});
//            Process process = Runtime.getRuntime().exec(
//                    new String[]{"wmic","baseboard","get" ,"serialnumber"});
            process.getOutputStream().close();
            Scanner sc = new Scanner(process.getInputStream());
            String property = sc.next();
            String serial = sc.next();
            if(res[3].trim().equals(serial) && res[2].equals("996") && res[0].equals("1")){

                /* 162 */     ServerConstants.服务器授权 = (String)authPair.getRight();
                /* 164 */     progressBarObservable.setProgress(new Pair("初始化数据库配置...", Integer.valueOf(30)));
                /* 165 */     this.dataBaseStatus = DatabaseConnection.getInstance().TestConnection();
                /* 166 */     InitializeServer.initializeRedis(false, progressBarObservable);
                /* 168 */     ThreadUtils.sleepSafely(1000L);
                /* 169 */     this.progress.setVisible(false);
            }else{
                WebOptionPane.showMessageDialog(instance, "未授权");
                System.exit(1);
            }
        }catch (Exception e){
            e.printStackTrace();
            WebOptionPane.showMessageDialog(instance, "授权出错");
            System.exit(1);
        }

        /* 171 */     contentPane.add(createOnlineStatus(), "North");
        /* 172 */     contentPane.add(createMainPane(), "Center");
        /* 173 */     contentPane.add(createStatusBar(), "South");
        /* 175 */     add((Component)contentPane);
        /* 177 */     progressBarObserver.deleteObserver(progressBarObservable);
        /* 178 */     progressBarObservable.deleteObservers();
        /* 180 */     setTitle("当前版本: v." + ServerConfig.LOGIN_MAPLE_VERSION + "." + ServerConfig.LOGIN_MAPLE_PATCH + " 最近更新时间:2020.8.6");
        /* 181 */     pack();
        /* 182 */     setLocationRelativeTo(null);
        /* 183 */     setDefaultCloseOperation(0);
        /* 184 */     addWindowListener(new WindowAdapter() {
            /*     */           public void windowClosing(WindowEvent e) {
                /* 187 */             int result = WebOptionPane.showConfirmDialog((Component)Start.instance, "确定要退出？", "警告", 0);
                /* 188 */             if (result == 0)
                    /* 189 */               System.exit(0);
                /*     */           }
            /*     */         });
        /* 194 */     SwingUtilities.invokeLater(DataManagePanel::getInstance);
        /* 196 */     System.setOut(new PrintStream(new NewOutputStram((byte)0)));
        /* 197 */     System.setErr(new PrintStream(new NewOutputStram((byte)1)));
        /*     */   }
    /*     */
    /*     */   public static Start getInstance() {
        /* 201 */     if (instance == null)
            /* 202 */       instance = new Start();
        /* 204 */     return instance;
        /*     */   }
    /*     */
    /*     */   public static ImageIcon loadIcon(String path) {
        /* 208 */     return new ImageIcon(Start.class.getResource("/icon/" + path));
        /*     */   }
    /*     */
    /*     */   public static ImageIcon getMainIcon() {
        /* 212 */     return loadIcon("1002140.png");
        /*     */   }
    /*     */
    /*     */   private static void checkSingleInstance() {
        /*     */     try {
            /* 217 */       new ServerSocket(26351);
            /* 218 */     } catch (IOException ex) {
            /* 219 */       if (ex.getMessage().contains("Address already in use: JVM_Bind")) {
                /* 220 */         WebOptionPane.showMessageDialog((Component)instance, "同一台电脑只能运行一个服务端，若因服务端未正常关闭，请在任务管理器内结束javaw.exe进程", "错误", 0);
                /* 221 */         System.out.println();
                /*     */       }
            /* 223 */       System.exit(0);
            /*     */     }
        /*     */   }
    /*     */
    /*     */   private static void run() {
        /* 228 */     getInstance().display();
        /* 229 */     getInstance().testDatabaseConnection();
        /*     */   }
    /*     */
    /*     */   public static void main(String[] args) {
        /* 233 */     checkSingleInstance();
        /* 234 */     FontUIResource fontUIResource = new FontUIResource("微软雅黑", 0, 12);
        /* 235 */     WebLookAndFeel.globalControlFont = fontUIResource;
        /* 236 */     WebLookAndFeel.globalTooltipFont = fontUIResource;
        /* 237 */     WebLookAndFeel.globalAlertFont = fontUIResource;
        /* 238 */     WebLookAndFeel.globalMenuFont = fontUIResource;
        /* 239 */     WebLookAndFeel.globalAcceleratorFont = fontUIResource;
        /* 240 */     WebLookAndFeel.globalTitleFont = fontUIResource;
        /* 241 */     WebLookAndFeel.globalTextFont = fontUIResource;
        /* 242 */     WebLookAndFeel.toolTipFont = fontUIResource;
        /* 243 */     WebLookAndFeel.textPaneFont = fontUIResource;
        /* 244 */     WebLookAndFeel.install();
        /* 246 */     run();
        /*     */   }
    /*     */
    /*     */   public static void showMessage(String error, String title, int type) {
        /* 250 */     WebOptionPane.showMessageDialog(null, error, title, type);
        /*     */   }
    /*     */
    /*     */   public String getServer_version() {
        /* 254 */     return this.server_version;
        /*     */   }
    /*     */
    /*     */   public void setDataBaseStatus(DatabaseConnection.DataBaseStatus dataBaseStatus) {
        /* 258 */     this.dataBaseStatus = dataBaseStatus;
        /*     */   }
    /*     */
    /*     */   private boolean testDatabaseConnection() {
        /* 262 */     if (!this.dataBaseStatus.equals(DatabaseConnection.DataBaseStatus.连接成功)) {
            /* 263 */       if (WebOptionPane.showConfirmDialog((Component)instance, "数据库连接失败，将转到配置页面，请务必通过测试连接，否则服务端无法启动", "", 2) == 0)
                /* 264 */         showConfigPanel();
            /* 266 */       return false;
            /*     */     }
        /* 268 */     return true;
        /*     */   }
    /*     */
    /*     */   private void display() {
        /* 272 */     SwingUtilities.invokeLater(() -> {
            /*     */           setVisible(true);
            /*     */           startCheckUpdate();
            /*     */         });
        /*     */   }
    /*     */
    /*     */   private StartFrame createProgressDialog() {
        /* 281 */     StartFrame progress = new StartFrame();
        /* 282 */     progress.setUndecorated(true);
        /* 283 */     progress.pack();
        /* 284 */     progress.setResizable(false);
        /* 285 */     progress.setLocationRelativeTo(null);
        /* 286 */     progress.setVisible(true);
        /* 288 */     return progress;
        /*     */   }
    /*     */
    /*     */   private Component createMainPane() {
        /* 292 */     WebPanel contentPane = new WebPanel();
        /* 294 */     contentPane.setLayout(new BorderLayout());
        /* 297 */     WebPanel runningLogPane = new WebPanel(new BorderLayout());
        /* 298 */     runningLogPane.setPainter((Painter)new TitledBorderPainter("运行日志")).setMargin(2);
        /* 299 */     runningLogPane.setPreferredSize(660, 300);
        /* 300 */     this.textPane = new WebTextPane();
        /* 301 */     this.textPane.setEditable(false);
        /* 302 */     this.textPane.setComponentPopupMenu((JPopupMenu)new WebPopupMenu() {
            /*     */
            /*     */         });
        /* 316 */     WebScrollPane textPaneScroll = new WebScrollPane((Component)this.textPane);
        /* 317 */     textPaneScroll.createVerticalScrollBar();
        /* 320 */     textPaneScroll.addMouseWheelListener(e -> {
            /*     */           WebScrollBar scrollBar = textPaneScroll.getWebVerticalScrollBar();
            /* 322 */           this.autoScroll = (e.getWheelRotation() != -1 && scrollBar.getMaximum() - scrollBar.getValue() <= scrollBar.getHeight());
            /*     */         });
        /* 325 */     runningLogPane.add((Component)textPaneScroll);
        /* 328 */     WebPanel menuPane = new WebPanel(new BorderLayout(5, 5));
        /* 329 */     menuPane.setUndecorated(false);
        /* 330 */     menuPane.setRound(StyleConstants.largeRound);
        /* 331 */     menuPane.setMargin(5);
        /* 332 */     menuPane.setShadeWidth(5);
        /* 334 */     WebButton serverConfig = new WebButton("配置参数", e -> (new SwingWorker<Object, Object>() {
            /*     */           protected Object doInBackground() throws Exception {
                /* 337 */             Start.this.showConfigPanel();
                /* 338 */             return null;
                /*     */           }
            /*     */         }).execute());
        /* 341 */     serverConfig.setMargin(5, 10, 5, 10);
        /* 344 */     WebButton dataManage = new WebButton("数据管理", e -> {
            /*     */           DataManagePanel dataManagePanel = DataManagePanel.getInstance();
            /*     */           dataManagePanel.pack();
            /*     */           dataManagePanel.setLocationRelativeTo(null);
            /*     */           dataManagePanel.setVisible(true);
            /*     */         });
        /* 350 */     dataManage.setMargin(5, 10, 5, 10);
        /* 355 */     WebButton delUserDataManage = new WebButton("数据库管理", e -> (new SwingWorker<Object, Object>() {
            /*     */           protected Object doInBackground() throws Exception {
                /* 358 */             ((WebButton)e.getSource()).setEnabled(false);
                /* 359 */             DataBaseManagePanel dataBaseManagePanel = DataBaseManagePanel.getInstance();
                /* 360 */             dataBaseManagePanel.pack();
                /* 361 */             dataBaseManagePanel.setLocationRelativeTo((Component)Start.instance);
                /* 362 */             dataBaseManagePanel.setVisible(true);
                /* 363 */             ((WebButton)e.getSource()).setEnabled(true);
                /* 364 */             return null;
                /*     */           }
            /*     */         }).execute());
        /* 367 */     delUserDataManage.setMargin(5, 10, 5, 10);
        /* 393 */     WebButton wzStringDumper = new WebButton("代码提取", e -> (new SwingWorker<Object, Object>() {
            /*     */           protected Object doInBackground() {
                /* 397 */             ((WebButton)e.getSource()).setEnabled(false);
                /* 398 */             WZStringDumperPane wzStringDumperPane = WZStringDumperPane.getInstance();
                /* 399 */             wzStringDumperPane.pack();
                /* 400 */             wzStringDumperPane.setLocationRelativeTo((Component)Start.instance);
                /* 401 */             wzStringDumperPane.setVisible(true);
                /* 402 */             ((WebButton)e.getSource()).setEnabled(true);
                /* 403 */             return null;
                /*     */           }
            /*     */         }).execute());
        /* 406 */     wzStringDumper.setMargin(5, 10, 5, 10);
        /* 408 */     ImageIcon start = loadIcon("start.png");
        /* 409 */     ImageIcon stop = loadIcon("stop.png");
        /* 410 */     final WebButton startServer = new WebButton("启动服务端", start);
        /* 411 */     WebProgressOverlay progressOverlay = new WebProgressOverlay();
        /* 412 */     progressOverlay.setConsumeEvents(false);
        /* 413 */     startServer.setMargin(5, 10, 5, 10);
        /* 415 */     progressOverlay.setComponent((Component)startServer);
        /* 416 */     progressOverlay.setOpaque(false);
        /* 417 */     startServer.addActionListener(e -> {
            /*     */           if (!testDatabaseConnection())
                /*     */             return;
            /*     */           boolean showLoad = !progressOverlay.isShowLoad();
            /*     */           if (showLoad) {
                /*     */             startRunTime();
                /*     */             this.start_thread.start();
                /*     */           } else {
                /*     */             String input = WebOptionPane.showInputDialog((Component)instance, "关闭倒计时(分钟)：", Integer.valueOf(0));
                /*     */             if (input == null)
                    /*     */               return;
                /*     */             startServer.setEnabled(false);
                /*     */             int time = Integer.valueOf(StringUtil.isNumber(input) ? input : "0").intValue();
                /*     */             ShutdownServer si = ShutdownServer.getInstance();
                /*     */             if (si == null) {
                    /*     */               WebOptionPane.showMessageDialog((Component)instance, "停止服务端发生错误，服务端似乎没有启动？\r\n\r\n请关闭服务端，确保进程内的java.exe和javaw.exe进程完全关闭，再启动服务端试试吧~", "错误", 0);
                    /*     */               System.exit(0);
                    /*     */             }
                /*     */             si.setTime(time);
                /*     */             Thread stop_thread = new Thread(() -> shutdownServer = Timer.GuiTimer.getInstance().register(() -> {
                    ShutdownServer.getInstance().shutdown();
                    if (si.getTime() > 0) {
                        System.out.println("距离服务端完全关闭还剩 " + si.getTime() + " 分钟，已通知玩家，请耐心等待...");
                    } else {
                        shutdownServer.cancel(false);
                        startRunTime.cancel(false);
                    }
                    si.setTime(si.getTime() - 1);
                }, 60000));
                /*     */             stop_thread.start();
                /*     */             try {
                    /*     */               stop_thread.join();
                    /* 452 */             } catch (InterruptedException e1) {
                    /*     */               log.error("停止服务端失败", e);
                    /*     */             }
                /*     */           }
            /*     */           progressOverlay.setShowLoad(showLoad);
            /*     */           startServer.setText(showLoad ? "停止服务端" : "启动服务端");
            /*     */           startServer.setIcon(showLoad ? stop : start);
            /*     */         });
        /* 468 */     menuPane.add((Component)new GroupPanel(false, new Component[] { (Component)(new WebSeparator(false, true))
/* 469 */             .setMargin(4, 0, 4, 0), (Component)serverConfig, (Component)(new WebSeparator(false, true))
/*     */
/* 471 */             .setMargin(4, 0, 4, 0), (Component)dataManage, (Component)(new WebSeparator(false, true))
/*     */
/* 473 */             .setMargin(4, 0, 4, 0), (Component)delUserDataManage, (Component)(new WebSeparator(false, true))
/*     */
/* 476 */             .setMargin(4, 0, 4, 0), (Component)wzStringDumper, (Component)(new WebSeparator(false, true))
/*     */
/* 480 */             .setMargin(4, 0, 0, 0) }), "North");
        /* 482 */     menuPane.add((Component)new GroupPanel(false, new Component[] { (Component)(new WebSeparator(false, true)).setMargin(4, 0, 4, 0), (Component)progressOverlay }), "South");
        /* 484 */     contentPane.add((Component)runningLogPane, "Center");
        /* 485 */     contentPane.add((Component)menuPane, "West");
        /* 488 */     addWindowListener(new WindowAdapter() {
            /*     */           public void windowOpened(WindowEvent e) {
                /* 491 */             startServer.requestFocus();
                /*     */           }
            /*     */         });
        /* 495 */     return (Component)contentPane;
        /*     */   }
    /*     */
    /*     */   public synchronized ConfigPanel showConfigPanel() {
        /* 499 */     ConfigPanel serverConfigFrame = new ConfigPanel((Frame)instance);
        /* 500 */     serverConfigFrame.pack();
        /* 501 */     serverConfigFrame.setLocationRelativeTo((Component)instance);
        /* 502 */     serverConfigFrame.setVisible(true);
        /* 503 */     return serverConfigFrame;
        /*     */   }
    /*     */
    /*     */   private void showBossPanel() {
        /* 507 */     (new SwingWorker<Object, Object>() {
            /*     */         protected Object doInBackground() throws Exception {
                /* 510 */           BossManagePanel bossManagePanel = new BossManagePanel((Frame)Start.instance);
                /* 511 */           bossManagePanel.pack();
                /* 512 */           bossManagePanel.setLocationRelativeTo((Component)Start.instance);
                /* 513 */           bossManagePanel.setVisible(true);
                /* 514 */           return null;
                /*     */         }
            /* 516 */       }).execute();
        /*     */   }
    /*     */
    /*     */   public synchronized void showUpdateServer() {
        /* 520 */     (new SwingWorker<Object, Object>() {
            /*     */         protected Object doInBackground() throws Exception {
                /* 523 */           UpdateServer updateServer = UpdateServer.getInstance(Start.instance);
                /* 524 */           updateServer.pack();
                /* 525 */           updateServer.setLocationRelativeTo((Component)Start.instance);
                /* 526 */           updateServer.setVisible(true);
                /* 527 */           return null;
                /*     */         }
            /* 529 */       }).execute();
        /*     */   }
    /*     */
    /*     */   private Component createOnlineStatus() {
        /* 533 */     GroupPanel groupPanel = new GroupPanel(5, new Component[0]);
        /* 534 */     groupPanel.setPainter((Painter)new TitledBorderPainter("在线人数"));
        /* 535 */     groupPanel.setMargin(5);
        /* 536 */     this.labels = new WebHotkeyLabel[ServerConfig.CHANNEL_PORTS + 1];
        /* 537 */     for (int i = 0; i <= ServerConfig.CHANNEL_PORTS; i++) {
            /* 538 */       WebHotkeyLabel label = new WebHotkeyLabel("频道" + (i + 1) + " : 0");
            /* 539 */       this.labels[i] = label;
            /* 540 */       groupPanel.add((Component)label);
            /*     */     }
        /* 542 */     return (Component)groupPanel;
        /*     */   }
    /*     */
    /*     */   public void setupOnlineStatus(int channel) {
        /* 546 */     ChannelServer channelServer = ChannelServer.getInstance(channel);
        /* 547 */     if (channelServer == null)
            /*     */       return;
        /* 550 */     PlayerStorage.PlayerObservable playerObservable = channelServer.getPlayerStorage().getPlayerObservable();
        /* 551 */     Observer observer = (o, arg) -> this.labels[channel - 1].setText("频道" + channel + " : " + playerObservable.getCount());
        /* 552 */     playerObservable.addObserver(observer);
        /*     */   }
    /*     */
    /*     */   private Component createBroadCastMsg() {
        /* 556 */     WebPanel contentPanel = new WebPanel(new BorderLayout(5, 5));
        /* 557 */     contentPanel.setPainter((Painter)new TitledBorderPainter("系统公告"));
        /* 558 */     contentPanel.setMargin(5);
        /* 560 */     String[] items = { "顶部黄色公告", "信息提示框", "蓝色公告", "红色公告", "白色公告" };
        /* 562 */     final WebComboBox comboBox = new WebComboBox((Object[])items);
        /* 563 */     contentPanel.add((Component)comboBox, "West");
        /* 565 */     final WebTextField textField = new WebTextField(ServerConfig.LOGIN_SERVERMESSAGE);
        /* 566 */     textField.setInputPrompt("点击此处输入您要发布的消息内容...");
        /* 567 */     textField.setHideInputPromptOnFocus(false);
        /* 568 */     contentPanel.add((Component)textField, "Center");
        /* 570 */     comboBox.addItemListener(e -> {
            /*     */           if (e.getItem().equals("顶部黄色公告")) {
                /*     */             textField.setText(ServerConfig.LOGIN_SERVERMESSAGE);
                /*     */           } else {
                /*     */             textField.setText("");
                /*     */           }
            /*     */         });
        /* 578 */     WebButton send = new WebButton("发送消息", e -> (new SwingWorker<Object, Object>() {
            /*     */           protected Object doInBackground() throws Exception {
                /* 581 */             if (!Start.startFinish) {
                    /* 582 */               WebOptionPane.showMessageDialog((Component)Start.instance, "服务端暂未启动，无法使用该功能");
                    /* 583 */               return null;
                    /*     */             }
                /* 585 */             String msg = textField.getText();
                /* 586 */             byte[] packet = new byte[0];
                /* 587 */             switch (comboBox.getSelectedIndex()) {
                    /*     */               case 0:
                        /* 589 */                 ServerConfig.LOGIN_SERVERMESSAGE = msg;
                        /* 590 */                 Config.setProperty("login.server.message", msg);
                        /* 591 */                 packet = MaplePacketCreator.serverMessage(msg);
                        /*     */                 break;
                    /*     */               case 1:
                        /* 594 */                 packet = MaplePacketCreator.serverNotice(1, msg);
                        /*     */                 break;
                    /*     */               case 2:
                        /* 597 */                 packet = MaplePacketCreator.serverNotice(6, msg);
                        /*     */                 break;
                    /*     */               case 3:
                        /* 600 */                 packet = MaplePacketCreator.serverNotice(5, msg);
                        /*     */                 break;
                    /*     */               case 4:
                        /* 603 */                 packet = MaplePacketCreator.spouseMessage(10, msg);
                        /*     */                 break;
                    /*     */             }
                /* 606 */             WorldBroadcastService.getInstance().broadcastMessage(packet);
                /* 607 */             WebOptionPane.showMessageDialog((Component)Start.instance, "发送完成");
                /* 608 */             return null;
                /*     */           }
            /*     */         }).execute());
        /* 611 */     contentPanel.add((Component)send, "East");
        /* 613 */     return (Component)contentPanel;
        /*     */   }
    /*     */
    /*     */   private Component createStatusBar() {
        /* 617 */     WebPanel contentPane = new WebPanel(new BorderLayout(5, 5));
        /* 618 */     WebStatusBar statusBar = new WebStatusBar();
        /* 620 */     statusBar.addSeparator();
        /* 621 */     this.authLimitTime = new WebLabel() {
            /*     */         public void setText(String text) {
                /* 624 */           super.setText(" 授权到期时间: " + text);
                /*     */         }
            /*     */       };
        /* 627 */     this.authLimitTime.setText(Authorization.AUTH_LIMIT_TIME + " 授权码:" + Authorization.AUTH_CODE);
        /* 634 */     statusBar.add((Component)this.authLimitTime);
        /* 639 */     statusBar.addSeparator();
        /* 640 */     statusBar.addToMiddle((Component)new WebLabel("") {
            /*     */
            /*     */         });
        /* 654 */     WebMemoryBar memoryBar = new WebMemoryBar();
        /* 655 */     memoryBar.setShowMaximumMemory(false);
        /* 656 */     memoryBar.setPreferredWidth((memoryBar.getPreferredSize()).width + 20);
        /* 657 */     statusBar.addToEnd((Component)memoryBar);
        /* 659 */     this.runningTimelabel = new WebHotkeyLabel("运行时长: 00天00:00:00");
        /* 660 */     statusBar.addToEnd((Component)this.runningTimelabel);
        /* 661 */     statusBar.addSeparatorToEnd();
        /* 664 */     contentPane.add(createBroadCastMsg(), "Center");
        /* 665 */     contentPane.add((Component)statusBar, "South");
        /* 667 */     return (Component)contentPane;
        /*     */   }
    /*     */
    /*     */   public void updateAuthLimitTime(String time) {
        /* 671 */     instance.authLimitTime.setText(time);
        /*     */   }
    /*     */
    /*     */   private void startRunTime() {
        /* 675 */     this.starttime = System.currentTimeMillis();
        /* 676 */     this.startRunTime = Timer.GuiTimer.getInstance().register(new Runnable() {
            /*     */           public void run() {
                /* 679 */             Start.this.runningTimelabel.setText(formatDuring(System.currentTimeMillis() - Start.this.starttime));
                /*     */           }
            /*     */
            /*     */           private String formatDuring(long mss) {
                /* 683 */             long days = mss / 86400000L;
                /* 684 */             long hours = mss % 86400000L / 3600000L;
                /* 685 */             long minutes = mss % 3600000L / 60000L;
                /* 686 */             long seconds = mss % 60000L / 1000L;
                /* 687 */             return "运行时长: " + ((days / 10L == 0L) ? "0" : "") + days + "天" + ((hours / 10L == 0L) ? "0" : "") + hours + ":" + ((minutes / 10L == 0L) ? "0" : "") + minutes + ":" + ((seconds / 10L == 0L) ? "0" : "") + seconds;
                /*     */           }
            /*     */         },  1000L);
        /*     */   }
    /*     */
    /*     */   private void startCheckUpdate() {
        /* 694 */     //Timer.GuiTimer.getInstance().register((Runnable)new UpdateServer.CheckUpdateRun(), 10000L);
        /*     */}
    /*     */
    /*     */   private static class StartThread implements Runnable {
        /*     */     private StartThread() {}
        /*     */
        /*     */     public void run() {
            /*     */       try {
                /* 702 */         System.out.println("准备启动服务端...");
                /* 703 */         if (!InitializeServer.Initial()) {
                    /* 704 */           System.out.println("服务端初始化失败。");
                    /*     */           return;
                    /*     */         }
                /* 708 */         System.out.println("正在启动 - 时钟管理器");
                /* 709 */         Timer.WorldTimer.getInstance().start();
                /* 710 */         Timer.EtcTimer.getInstance().start();
                /* 711 */         Timer.MapTimer.getInstance().start();
                /* 712 */         Timer.CloneTimer.getInstance().start();
                /* 713 */         Timer.EventTimer.getInstance().start();
                /* 714 */         Timer.BuffTimer.getInstance().start();
                /* 715 */         Timer.PingTimer.getInstance().start();
                /* 716 */         Timer.PlayerTimer.getInstance().start();
                /* 718 */         System.out.println("正在启动 - 好友、组队、家族、联盟、角色管理");
                /* 719 */         World.init();
                /* 720 */         MapleGuildRanking.getInstance().load();
                /* 721 */         MapleGuild.loadAll();
                /* 722 */         MapleFamily.loadAll();
                /* 725 */         System.out.println("正在加载 - 道具信息");
                /* 726 */         MapleItemInformationProvider.getInstance().runEtc();
                /* 731 */         System.out.println("正在加载 - 初始角色信息");
                /* 732 */         LoginInformationProvider.getInstance();
                /* 734 */         System.out.println("正在加载 - 随机奖励");
                /* 735 */         RandomRewards.load();
                /* 737 */         System.out.println("正在加载 - 角色卡系统");
                /* 738 */         CharacterCardFactory.getInstance().initialize();
                /* 740 */         System.out.println("正在加载 - 副本竞速排行榜");
                /* 741 */         SpeedRunner.loadSpeedRuns();
                /* 743 */         System.out.println("正在加载 - 拍卖行系统");
                /* 744 */         MTSStorage.load();
                /* 748 */         LoginServer.run_startup_configurations();
                /* 749 */         ChannelServer.startChannel_Main();
                /* 750 */         CashShopServer.run_startup_configurations();
                /* 751 */         AuctionServer.run_startup_configurations();
                /* 752 */         ChatServer.run_startup_configurations();
                /* 754 */         System.out.println("正在加载 - 其他信息");
                /* 755 */         Timer.CheatTimer.getInstance().register((Runnable)AutobanManager.getInstance(), 60000L);
                /* 756 */         WorldRespawnService.getInstance();
                /* 757 */         ShutdownServer.registerMBean();
                /* 758 */         LoginServer.setOn();
                /* 759 */         PredictCardFactory.getInstance().initialize();
                /* 760 */         MapleInventoryIdentifier.getInstance();
                /* 761 */         MapleItemInformationProvider.getInstance().initSealedEquipInfo();
                /* 762 */         PlayerNPC.loadAll();
                /* 763 */         MapleDojoRanking.getInstance().load(false);
                /* 764 */         RankingWorker.start();
                /* 765 */         PlayMSEvent.start();
                /* 766 */         MessengerRankingWorker.getInstance();
                /* 767 */         MapleSignin.getInstance().load();
                /* 770 */         RankingTop.getInstance();
                /* 771 */         DataBaseManagePanel.getInstance().autoBackup();
                /* 772 */         OpcodeConfig.load();
                /* 773 */         MapleCarnivalFactory.getInstance();
                /* 774 */         ItemConstants.TapJoyReward.init();
               // /* 775 */         MapleUnionFactory.INSTANCE.init();
                /* 776 */         Runtime.getRuntime().addShutdownHook(new Thread(new Start.Shutdown()));
              //  /* 778 */         CommandProcessor.init();
               // /* 779 */         AutoExecuteTask.execute();
                /* 780 */         System.err.println("服务端启动完成！");
                /* 781 */         Start.log.info("服务端启动完成！");
                /* 782 */         Start.startFinish = true;
                /* 783 */       } catch (Exception e) {
                /* 784 */         System.err.println("服务端启动失败！");
                /* 785 */         Start.log.fatal("服务端启动失败", e);
                /*     */       }
            /*     */     }
        /*     */   }
    /*     */
    static class NewOutputStram extends OutputStream {

        private final byte type;

        public NewOutputStram(byte type) {
            this.type = type;
        }

        @Override
        public void write(int b) throws IOException {

        }

        @Override
        public void write(final byte[] b, final int off, final int len) throws IOException {
//            super.write(b, off, len);
            final SimpleAttributeSet set = new SimpleAttributeSet();
            switch (type) {
                case 0:
                    javax.swing.text.StyleConstants.setForeground(set, Color.BLACK);
                    break;
                case 1:
                    javax.swing.text.StyleConstants.setForeground(set, Color.RED);
                    break;
                case 2:
                    javax.swing.text.StyleConstants.setForeground(set, Color.BLUE);
                    break;
            }

            try {
                WebTextPane textPane = Start.getInstance().textPane;

                textPane.getDocument().insertString(textPane.getDocument().getLength(), new String(b, off, len), set);
                if (Start.getInstance().autoScroll) {
                    textPane.setCaretPosition(textPane.getDocument().getLength());
                }
            } catch (BadLocationException e) {
                log.fatal("控制台输出失败", e);
            }
        }
    }
    /*     */
    /*     */   private static class Shutdown implements Runnable {
        /*     */     private Shutdown() {}
        /*     */
        /*     */     public void run() {
            /* 836 */       ShutdownServer.getInstance().run();
            /*     */     }
        /*     */   }
    /*     */
    /*     */   public class StartFrame extends WebFrame {
        /*     */     private final WebLabel titleText;
        /*     */
        /*     */     private final WebProgressBar progressBar;
        /*     */
        /* 847 */     private final ImageIcon background = Start.loadIcon("LOGO.png");
        /*     */
        /*     */     StartFrame() {
            /* 853 */       setDefaultCloseOperation(3);
            /* 854 */       setPreferredSize(new Dimension(this.background.getIconWidth(), this.background.getIconHeight()));
            /* 856 */       BackgroundPanel backgroundPanel = new BackgroundPanel();
            /* 858 */       backgroundPanel.setLayout(new BorderLayout());
            /* 860 */       this.titleText = (new WebLabel("正在启动……", 0, new Object[0])).setMargin(0, 0, 3, 0);
            /* 861 */       this.titleText.setForeground(Color.WHITE);
            /* 862 */       this.titleText.setFont(new FontUIResource("微软雅黑", 0, 12));
            /* 863 */       this.progressBar = new WebProgressBar(0, 100);
            /* 864 */       this.progressBar.setPreferredHeight(5);
            /* 865 */       this.progressBar.setStringPainted(false);
            /* 866 */       this.progressBar.setRound(0);
            /* 867 */       this.progressBar.setValue(0);
            /* 868 */       this.progressBar.setShadeWidth(0);
            /* 869 */       this.progressBar.setBorderPainted(false);
            /* 870 */       this.progressBar.setProgressBottomColor(Color.CYAN);
            /* 871 */       this.progressBar.setProgressTopColor(Color.BLACK);
            /* 873 */       backgroundPanel.add((Component)new GroupPanel(false, new Component[] { (Component)this.titleText, (Component)this.progressBar }), "South");
            /* 875 */       add((Component)backgroundPanel);
            /*     */     }
        /*     */
        /*     */     public void setText(String text) {
            /* 879 */       this.titleText.setText(text);
            /*     */     }
        /*     */
        /*     */     public void setProgress(int value) {
            /* 883 */       this.progressBar.setValue(value);
            /*     */     }
        /*     */
        /*     */     private class BackgroundPanel extends WebPanel {
            /*     */       private BackgroundPanel() {}
            /*     */
            /*     */       public void paintComponent(Graphics g) {
                /* 889 */         g.drawImage(Start.StartFrame.this.background.getImage(), 0, 0, null);
                /*     */       }
            /*     */     }
        /*     */   }
    /*     */
    /*     */   public class ProgressBarObservable extends Observable {
        /*     */     private String text;
        /*     */
        /*     */     private int progress;
        /*     */
        /*     */     public int getProgress() {
            /* 899 */       return this.progress;
            /*     */     }
        /*     */
        /*     */     public void setProgress(Pair<String, Integer> value) {
            /* 903 */       this.text = (String)value.getLeft();
            /* 904 */       this.progress = ((Integer)value.getRight()).intValue();
            /* 905 */       setChanged();
            /* 906 */       notifyObservers(value);
            /*     */     }
        /*     */   }
    /*     */
    /*     */   private class ProgressBarObserver implements Observer {
        /*     */     ProgressBarObserver(Start.ProgressBarObservable progressBarObservable) {
            /* 912 */       progressBarObservable.addObserver(this);
            /*     */     }
        /*     */
        /*     */     public void deleteObserver(Start.ProgressBarObservable progressBarObservable) {
            /* 916 */       progressBarObservable.deleteObserver(this);
            /*     */     }
        /*     */
        /*     */     public void update(Observable o, Object arg) {
            /* 921 */       if (arg instanceof Pair) {
                /* 922 */         Pair pair = (Pair)arg;
                /* 923 */         Start.this.progress.setText((String)pair.getLeft());
                /* 924 */         Start.this.progress.setProgress(((Integer)pair.getRight()).intValue());
                /*     */       }
            /*     */     }
        /*     */   }
    /*     */ }


/* Location:              D:\MapleStory\maplerServer\zdms\Server原包.jar!\server\console\Start.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */